Run this from the stat436_notes root directory to compile all course notes.

Clean up previous builds

# Remove any existing HTML files in post directories
unlink(list.files("_posts", pattern = "*.html", recursive = TRUE, full.names = TRUE))

# Clear cache directories
system("find _posts -type d -name '*cache*' -exec rm -rf {} +")
system("find _posts -type d -name '*files*' -exec rm -rf {} +")

Compile individual posts

library(tidyverse)
library(rmarkdown)
library(distill)

# Find all .Rmd files in _posts subdirectories
files <- list.files(path = "_posts", pattern = "*.Rmd", recursive = TRUE, full.names = TRUE)

# Exclude the compile script itself
files <- setdiff(files, c("_posts/compile.Rmd"))

# Render each individual post
cat("Found", length(files), "files to render:\n")
for (i in seq_along(files)) {
  cat("Rendering", i, "of", length(files), ":", files[i], "\n")
  tryCatch({
    render(files[i])
  }, error = function(e) {
    cat("Error rendering", files[i], ":", e$message, "\n")
  })
}

Render the full site

# Now render the complete site
render_site()

Instructions

To use this script:

  1. Make sure you’re in the root directory of your project
  2. Run each chunk manually or knit this document
  3. Check the docs/ directory for the compiled site

The script will: - Clean up any previous builds - Render each individual course note - Compile the main site with proper navigation